#ifndef TIMER_H_
#define TIMER_H_
/*********************************************************/
#include "misc/Event.h"

#include <Poco/Runnable.h>
#include <Poco/Thread.h>
#include <Poco/Mutex.h>

#define TIMER_INTERVAL	10			// Sets how many milliseconds the timer waits before checking its value
/*********************************************************/
class Timer : public Poco::Runnable
{
private:
	// Variables
	Poco::Thread		lThread;		// Local thread handle
	Poco::Mutex		mutex;			// mutual exclusion object
	Event*			event;			// Pointer to the event to flag when the timer runs out
	unsigned long		timeout;		// Time to wait before the timer flags the event
	bool			quit;			// Quit flag for the timer
	bool			persistant;		// Does the timer flag the event once or every interval milliseconds?

	// Methods
	void run();					// Keeps the thread in suspended mode until the timer runs out

protected:
public:
	// Methods
	void stop();					// Stop the timer
	

	// Construction & Destruction
	Timer(std::string event, unsigned int timeout, bool persistant);
	virtual ~Timer();
};
/*********************************************************/
#endif // TIMER_H_

